//
//  FQMineAdCollectionViewCell.swift
//  SwiftProject
//
//  Created by 董駸 on 2023/4/11.
//

import UIKit

class FQMineAdCollectionViewCell: UICollectionViewCell {
    var model : FQMineAdModel!
    var buttonBlock : (()->Void)?

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        contentView.backgroundColor = .colorMake(26, 63, 146)
        layer.cornerRadius = 8
        clipsToBounds = true
        
        let titleLb = QMUILabel(font: .rSFont(14), textColor: .white)
        titleLb.text = "最高可借(元)"
        contentView.addSubview(titleLb)
        
        titleLb.snp.makeConstraints { make in
            make.left.equalTo(20)
            make.top.equalTo(24)
        }
        
        let amountLb = QMUILabel(font: .mSFont(38), textColor: .white)
        amountLb.text = "200,000"
        contentView.addSubview(amountLb)
        
        amountLb.snp.makeConstraints { make in
            make.left.equalTo(titleLb)
            make.top.equalTo(titleLb.snp.bottom).offset(16)
        }
        
        let activateBtn = QMUIFillButton(fill: .white, titleTextColor: .colorMake(26, 63, 146))
        activateBtn.titleLabel?.font = .mSFont(16)
        activateBtn.setTitle("去申请", for: .normal)
        activateBtn.addTarget(self, action: #selector(buttonClick), for: .touchUpInside)
        contentView.addSubview(activateBtn)
        
        activateBtn.snp.makeConstraints { make in
            make.right.equalTo(-27)
            make.width.equalTo(84)
            make.centerY.equalTo(amountLb)
            make.height.equalTo(33)
        }
    }
    
    @objc func buttonClick() {
        buttonBlock?()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
